import { ILv70DramaStepCommand } from "../interfaces/ILv70DramaStepCommand";
import { TDrama } from "../../../../../Message/Db/Tables/TDrama";
import { GameController } from "../../../mvc/GameController";
import { PetUtil } from "../../pet/info/PetUtil";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
//class Lv70OpPetHide
    
    export  class Lv70OpPetHide implements ILv70DramaStepCommand
    {
        

        public call(arg1: TDrama, arg2: Function=null): void
        {
            var loc1=GameController.gameui.getGameui().getPetAvatarSPetInfo();
            if (loc1 && PetUtil.isBattled(loc1)) 
            {
                this._isPreFighting = true;
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetRest));
            }
            if (arg2 != null) 
            {
                arg2.apply();
            }
            return;
        }

        public cancel(arg1: TDrama, arg2: Function=null): void
        {
            var loc1=GameController.gameui.getGameui().getPetAvatarSPetInfo();
            if (loc1 && !PetUtil.isBattled(loc1) && this._isPreFighting) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetBattle, loc1));
            }
            if (arg2 != null) 
            {
                arg2.apply();
                this._isPreFighting = false;
            }
            return;
        }

        public dispose(): void
        {
            return;
        }

        /* internal */ /* var */_isPreFighting: Boolean=false;
    }
